<?php echo $header; ?>
<!-- End header -->

<!-- Begin content --> 
    <div id="main" class="p13t">
        <?php echo $column_left; ?>
        
        <div id="col2" class="w709">
            <div class="box_tt">
                <h4 class="p5t float_left">SENESTE NYHEDER</h4>
                <p class="float_right p5r" style="margin-right:3px;"><a href="<?php echo $news_link; ?>"><img src="catalog/view/theme/<?php echo $template; ?>/images/bt_tibage.png" width="85" height="31" /></a></p>
            </div>
            <div class="box_content_underpage">
                <div class="box_content_underpage1 min_heght">
                    <!-- content -->
                    <div id="content_item_detail" class="text_news">
                        <p class=" text_tt p15b"><?php echo $short_title; ?></p>
                        <div class="p10b">                            
                            <div class="box_bt_right float_left">
                                <div class="bt_send_event"><a href="<?php echo $tell_friend; ?>"></a></div>
                                <div class="bt_facebook">
                                    <a href="http://www.facebook.com/#!/pages/Gilleleje-Denmark/Havhokeren/120681221280479" onclick="return fbs_click()" target="_blank"></a>                                  
                                </div>
                                <!-- div class="bt_twitter">
                                    <a href="http://twitter.com/login?redirect_after_login=%2Fhome%3Fstatus%3Dhttp%3A%2F%2Fnyhederne.tv2.dk%2Farticle.php%2Fid-35170936%3Aclinton-er-f%25C3%25A6rdig-som-stemmej%25C3%25A6ger.html" target="_blank"></a>
                                </div -->
                            </div>
                            <?php if($image){ ?>
                                <div class="float_right m10r">
                                    <img src="<?php echo $image; ?>" title="<?php echo $title; ?>" alt="<?php echo $title; ?>" />
                                </div>
                            <?php } ?>
                            <p class="cb"></p>
                        </div>
                  
                        <div  class="osX">
                            <div id="pane" class="scroll-pane p20r">
                                <?php echo $text; ?>                                            
                            </div>
                        </div>    
                    </div>  
                    
                    <!-- popup tell friend -->
                    <div id="conten_item_popup" class="box_all_pop3" style="display:none;">
                        <div class="box_all_pop_line_tt">
                            <h1 class="p13t p10b p15l float_left">Send til en ven</h1>
                            <p class="float_right p13t p15r"><a id="close_item_popup" href="#"><img src="catalog/view/theme/<?php echo $template; ?>/images/icon_close.png" /></a></p>
                            <p class="cb"></p>
                        </div>
                        <div class="box_even_pu p20l p13t">
                        	<p class="p15b" style="display:none"><h3 id="send_finish_msg" style="color:#000; font-weight:bold; text-transform:none;"></h3></p>
                            <form id="send_to_friend" name="send_to_friend" action="<?php echo str_replace('&', '&amp;', $tell_friend); ?>" method="post">
                                <p class="p15b" style="display:none">Du har valgt at sende:<b> Clinton er færdig som stemmejæger</b></p>
                                <label>Modtager: </label>
                                <input class="txt_even_pu required" name="to_name" type="text" /><br class="cb" />
                                <label>Modtagers email-adresse: </label>
                                <input class="txt_even_pu required email" name="to_email" type="text" /><br class="cb" />
                                <label>Afsender: </label>
                                <input class="txt_even_pu" name="from_name" type="text" /><br class="cb" />
                                <label>Din email-adresse: </label>
                                <input class="txt_even_pu required email" name="from_email" type="text" /><br class="cb" />
                                <label>Evt. besked til modtageren: </label>
                                <textarea class="required" name="message" cols="" rows=""></textarea><br class="cb" />
                                <label>&nbsp;</label>
                                <input id="content_item_send" name="button_send" type="image" src="catalog/view/theme/<?php echo $template; ?>/images/bt_send2.jpg" /><br class="cb" />
                            </form>
                        </div>
                        <div>
                            <div class="cl"></div>
                        </div>
                    </div>
                                 
                </div>
            </div>
            <div class="box_bottom"></div>
        </div>
        <p class="cb"></p>
    </div>
</div>
<!-- End content -->    

<script type="text/javascript">
//<!--
    //var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
	var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,6})+$/;
	var numeric_filter = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)|(^-?\d*$)/;
	var error = false;
	var link = <?php echo "'" . $send_link . "'"; ?>;
	var messages_def = 'Jeg fandt dette link og tror at det kunne have interesse for dig.\n\n' + link;
    
    jQuery(document).ready(function(){
        jQuery('#pane').jScrollPane({scrollbarWidth: 16});
        
        // Open popup
        jQuery('.bt_send_event a').click(function(event){
            event.preventDefault();
            
            /*
            jQuery('#send_to_friend p').hide();
            jQuery('#conten_item_popup').show(); 
            jQuery('#content_item_detail').hide();
            */
			
			jQuery('#send_to_friend textarea[name=message]').val(messages_def);
			
			jQuery('#conten_item_popup').modal({
				closeHTML: "",
				opacity: 70,
				overlayCss: {
					height: 700,
				},					
				containerCss:{	
					background: "none",
					border: "none",	
					color: "#000",				
					height: "auto",
					width: "auto",
					padding: 0					
				}
			});       
        });
        
        // Close popup and reset form 
        jQuery('a#close_item_popup').click(function(event){
            event.preventDefault();
            
            //jQuery('#conten_item_popup').hide();  
            //jQuery('#content_item_detail').show();              
             
            jQuery('#send_to_friend').children().each(function(){
                if(jQuery(this).is('input') || jQuery(this).is('textarea')){
                    jQuery(this).val('');
        			if(jQuery(this).hasClass('errorField')){
        				jQuery(this).removeClass('errorField');                    
        			}
                }			
    		});
			jQuery.modal.close();  
        })
        
        // Check required fields
        jQuery('#send_to_friend .required').blur(function(){
            error = checkRequired(this);
        });
        
        // Process ajax call
        jQuery('#content_item_send').click(function(event){
            event.preventDefault();
            
            jQuery('#send_to_friend .required').each(function(){
    			error = error || checkRequired(this);		
    		}); 
            
            // Uses ajax to call send mail to friend function if has no error. 
            if(!error){
                jQuery.post(
                    jQuery('#send_to_friend').attr('action'),  
                    {
                        'from_name'     : jQuery('#send_to_friend input[name=from_name]').val(), 
                        'from_email'    : jQuery('#send_to_friend input[name=from_email]').val(),
                        'to_name'       : jQuery('#send_to_friend input[name=to_name]').val(), 
                        'to_email'      : jQuery('#send_to_friend input[name=to_email]').val(),
                        'message'       : jQuery('#send_to_friend textarea[name=message]').val(),
						'link'       	: link
                    },                
                    function(data){                        
                        if(data == 1){
                            /*
                            var name = jQuery('#send_to_friend input[name=to_name]').val();
                            var email = jQuery('#send_to_friend input[name=to_email]').val();
                            var message = 'Du har valgt at sende:';							
                            
                            if(name != ''){
                                message += ' <b>' + name + '<b/>'; //' (' + email + ')<b/>';    
                            }
                            else{
                                message += ' <b>' + email + '<b/>';
                            }                            							
							
                            jQuery('#send_to_friend p').html(message);
                            jQuery('#send_to_friend p').show();   
                            jQuery('#send_to_friend input[name=to_name]').val('');
                            jQuery('#send_to_friend input[name=to_email]').val('');
                            */
							
							var message = 'Din besked er sendt til en ven!';
							jQuery('#send_finish_msg').html(message);
							jQuery('#send_finish_msg').show();
							jQuery('#send_to_friend').hide();							
                        }   
                    }
                ); 
        
                  
            }   
        })    
    });
    
	function checkRequired(element){
		var element_error = false;		  
        element_error = jQuery(element).val() == '';
         
		if(!element_error){
			if(jQuery(element).hasClass('email')){
				element_error = !mail_filter.test(jQuery(element).val());
			}
			
			if(jQuery(element).hasClass('telephone')){
				element_error = (jQuery(element).val().length < 6) || !numeric_filter.test(jQuery(element).val());	
			}
			
			if(jQuery(this).hasClass('postcode')){
				element_error = (jQuery(element).val().length != 4) || !numeric_filter.test(jQuery(element).val());
			}
		}
		
		if(element_error){
			if(!jQuery(element).hasClass('errorField')){
				jQuery(element).addClass('errorField');
			}			
		}
		else{
			if(jQuery(element).hasClass('errorField')){
				jQuery(element).removeClass('errorField');
			}	
		}
		
		return element_error;
	}  
    
    function fbs_click(){
        u = '<?php echo str_replace("&", "&amp;", $send_link); ?>';
        t = document.title;
        o = 'toolbar=0,status=0,width=626,height=436';
        window.open('http://www.facebook.com/sharer.php?u=' + u + '&t=' + encodeURIComponent(t), 'sharer', o);
        
        return false;
    }    
//-->
</script>


<!-- Footer -->
<?php echo $footer; ?> 